package Day021_反射_注解.ZuoYe;

import java.lang.reflect.Method;

/**
 * @author zhangyan
 * @date 2020/5/15 16:38
 */
public class Test6 {
    @Book(value = "傲慢与偏见", price = 100, authors = {"简·奥斯汀"})
    public void aaa() {

    }

    public static void main(String[] args) throws Exception {

        //获取Class对象
        Class c = Test6.class;
        //获取方法
        Method m = c.getMethod("aaa");
        //解析注释
        //判断是否是注释
        if (m.isAnnotationPresent(Book.class)) {
            Book b = m.getAnnotation(Book.class);
            System.out.println(b);
        }
    }
}
